Courses / C++ Learning / Loops
Loops
Mark as CompleteRepeat actions with for, while, and do-while.
Loop Types
foris best when you know the count.whileruns while a condition is true.do-whileruns at least once.
Key takeaway: use loops to reduce repetition.
Example
for (int i = 0; i < 3; i++) {
std::cout << i << "\n";
}
Ready to try it yourself?
Loop through an array and print values.
← Arrays
Pointers →